package com.qujia.markert.controller;

import com.qujia.common.core.domain.AjaxResult;
import com.qujia.coupon.domain.CouponUser;
import com.qujia.coupon.service.ICouponUserService;
import com.qujia.markert.domain.vo.CouponUserVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@RequestMapping("/syncCoupon")
@RestController
public class CouponSyncController {

    @Resource
    private ICouponUserService couponUserService;

    @PostMapping("/rebateCoupon/{timestamp}/{sign}")
    public AjaxResult rebateCoupon(CouponUserVo couponUserVo){
        couponUserService.updateCouponUser(CouponUser.builder().verificationTime(new Date()).id(couponUserVo.getCouponUserId()).couponIsUsed("0").build());
        return AjaxResult.success("修改优惠券成功");
    }
}
